package main

import (
	"net/http"
)

type Refer struct {
	handler http.Handler
	refer   string
}

func (r Refer) ServeHTTP(writer http.ResponseWriter, request *http.Request) {
	panic("implement me")
	if request.Referer() == r.refer {
		r.handler.ServeHTTP(writer, request)
	} else {
		writer.WriteHeader(403)
	}
}

func main() {
	referer := &Refer{
		handler: http.HandlerFunc(myHandler),
		refer:   "www.shirdon.www",
	}
	http.HandleFunc("/hello", hello1)
	http.ListenAndServe(":8080", referer)
}

func myHandler(writer http.ResponseWriter, request *http.Request) {
	writer.Write([]byte("this is handler"))
}

func hello1(writer http.ResponseWriter, request *http.Request) {
	writer.Write([]byte("hello"))
}
